<?php
include('../../inc/global.inc');
include("../islogin.php");
?>
<?php
if($_POST[tj_act]){
mysql_query("insert into hot_link (hot_id,link_name,link_url) values ('$_POST[hot_id]','$_POST[link_name]','$_POST[link_url]')");
echo "<script>alert('添加成功');location='link.php';</script>";
}
?>
<?php
if($_POST['xg_act']){
mysql_query("update hot_link set hot_id='$_POST[hot_id]',link_name='$_POST[link_name]',link_url='$_POST[link_url]' where id='".$_POST['iid']."'");
echo "<script>alert('修改成功');location='link.php';</script>";
}
?>
<HTML>
<HEAD>
<TITLE>Admin</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<LINK href="../css/css.css" rel=stylesheet>
<script type='text/javascript' src="../js/islogin.js" charset="gb2312"></script>
</HEAD>
<BODY>
<center>
<table width="700" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
    <tr>
      <td height="25" bgcolor="#EEEEF9" style="padding-left:5px;">热点产品·友情链接&nbsp;&nbsp;<a href="javascript:history.go(-1)">返回</a></td>
    </tr>
  </table>
<?php
  if($_GET[tj]){
?>
<table width="700" border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#000000" >
<form action="" method="post" name="form1" onSubmit="return check()">
	<tr align='center' bgcolor='#D8EAF4'>
	  <td height="35" colspan="2" valign="middle" nowrap bgcolor="#8DA8CF" class='category'>添加链接</td>
	</tr>
<tr align='center' bgcolor='#FFFFFF'>
  <td width="151" align="center" bgcolor="#8DA8CF">分类【ID】</td>
  <td width="530" align="left" bgcolor="#FFFFFF" style="padding-left:5px"><input name="hot_id" type="text" size="10">
    限制数字</td>
</tr>
<tr align='center' bgcolor='#FFFFFF'>
  <td align="center" bgcolor="#8DA8CF">链接名称</td>
  <td width="530" align="left" bgcolor="#FFFFFF" style="padding-left:5px"><input name="link_name" type="text" size="20"></td>
</tr>
<tr align='center' bgcolor='#FFFFFF'>
  <td align="center" bgcolor="#8DA8CF">链接地址</td>
  <td align="left" bgcolor="#FFFFFF" style="padding-left:5px"><input name="link_url" type="text" value="http://" size="40"></td>
</tr>
  <tr align='center' bgcolor='#FFFFFF'><input type="hidden" name="tj_act" value="ok">
  <td colspan="2"><input type="submit" value="添加"></td>
  </tr>
  </form>
</table>
<?php }?>
<?php
  if($_GET['xg']){
  $row=mysql_fetch_array(mysql_query("select * from hot_link  where id='".$_GET['xg_id']."'"));
?>
<table width="700" border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#000000" >
<form action="" method="post" name="form1" onSubmit="return check()">
	<tr align='center' bgcolor='#D8EAF4'>
	  <td height="35" colspan="2" valign="middle" nowrap bgcolor="#8DA8CF" class='category'>修改信息</td>
	</tr>
<tr align='center' bgcolor='#FFFFFF'>
  <td width="149" align="center" bgcolor="#8DA8CF">选择分类</td>
  <td width="532" align="left" bgcolor="#FFFFFF" style="padding-left:5px"><input name="hot_id" type="text" size="10" value="<?=$row[hot_id]?>">
    限制数字</td>
</tr>
<tr align='center' bgcolor='#FFFFFF'>
  <td align="center" bgcolor="#8DA8CF">链接名称</td>
  <td width="532" align="left" bgcolor="#FFFFFF" style="padding-left:5px"><input name="link_name" type="text" size="20" value="<?=$row[link_name]?>"></td>
</tr>
<tr align='center' bgcolor='#FFFFFF'>
  <td align="center" bgcolor="#8DA8CF">链接地址</td>
  <td align="left" bgcolor="#FFFFFF" style="padding-left:5px"><input name="link_url" type="text" value="<?=$row[link_url]?>" size="40"></td>
</tr><input type="hidden" name="iid" value="<?=$row['id']?>">
  <tr align='center' bgcolor='#FFFFFF'><input type="hidden" name="xg_act" value="ok">
  <td colspan="2"><input type="submit" value="修改"></td>
  </tr>
  </form>
</table>
<?php }?>
</center>
</BODY>
</HTML>

<script language="javascript">
function $(id){
return document.getElementById(id);
}
function check(){
if($("hot_id").value==""){
alert("编号不能为空");
$("hot_id").focus();
return false
}

if(isNaN($("hot_id").value)){
alert("编号为数字");
$("hot_id").focus();
return false; 
}
if($("link_name").value==""){
alert("网站名称不能为空");
$("link_name").focus();
return false;
}
if($("link_url").value==""){
alert("链接地址不能为空");
$("link_url").focus();
return false;
}
}
</script>